using System;
using System.Collections.Generic;
using System.Text;
using PH.Common;

namespace Hoshimi
{
    public class ShooterBot_RestState : State
	{
		#region Singleton

		// Fields
		protected static ShooterBot_RestState instance;

		// Constructor
		protected ShooterBot_RestState() : base() { }

		// Methods
		public static ShooterBot_RestState Instance()
		{
			// Uses "Lazy initialization"
			if( instance == null ) 
				instance = new ShooterBot_RestState();

			return instance;
		}

		#endregion

		public override bool Play( Unit unit ) 
        {
			ShooterBot bot = (ShooterBot) unit;

			if (bot.State == NanoBotState.Defending)
			{
				return true;
			}

            bot.SetName("Rest");

			bot.UpdateEnnemyTarget();

            if (bot.HasTargetLocation())
            {
				bot.StopIfMoving();
                unit.myStateMachine.ChangeState(ShooterBot_MoveToTargetState.Instance());
                return false;
            }

			bot.MoveToOpponentAILocation();

			return true;
		}
	}
}
